from random import randrange

from tree import *

def test_simple():
    root = Node()
    c1 = BinaryNode(left=Node(randrange(-100, 100)), right=Node(randrange(-100, 100)))
    c2 = BinaryNode(left=Node(randrange(-100, 100)), right=Node(randrange(-100, 100)))
    root.left = c1
    root.right = c2
    print "Left: %s" % root.left.value
    print "Right: %s" % root.right.value
    print "\n"

def test_just_leaves_tree():
    print "test_just_leaves_tree"
    root = just_leaves_tree(2)
    print "Root: %r" % root.value 
    print "Left: %s" % root.left.value
    print "Right: %s" % root.right.value
    print "Left -> Left: %s" % root.left.left
    print "\n"

def test_minimax_tree(root):
    print "test_minimax_tree"    
    minimax_root = minimax_tree(root)
    print "Minimax: %s" % root.value
    print "Left: %s" % root.left.value
    print "Right: %s" % root.right.value
    print "Left -> Left: %s" % root.left.left
    print "Left -> Right: %s" % root.left.right
    print "Left -> Left -> Left: %s" % root.left.left.left
    print "Left -> Left -> Right: %s" % root.left.left.right
    print "Left -> Left -> Left -> Left -> Left: %s" % root.left.left.left.left.left
    print "\n"
        
#
# Run test
test_just_leaves_tree()

root = just_leaves_tree(20)
test_minimax_tree(root)
